package org.geektimes.http.server.jdk.servlet.matcher.impl;

import org.geektimes.http.server.jdk.servlet.matcher.URLPatternsMatcher;
import org.springframework.util.AntPathMatcher;

import javax.annotation.Priority;
import java.util.Collection;

/**
 * 实现 ANT 风格语义，可以参考 Spring
 * @link org.springframework.security.web.util.matcher.AntPathRequestMatcher
 * @author wenl
 */
@Priority( value=2 )
public class AntPathURLPatternsMatcher  implements URLPatternsMatcher {
    AntPathMatcher antPathMatcher = new AntPathMatcher();
    @Override
    public boolean matches( Collection<String> urlPatterns, String requestURI ) {
        for (String urlPattern : urlPatterns) {
           if( antPathMatcher.match( urlPattern, requestURI )){
               return true;
           }
        }
        return false;
    }
}
